/* eslint-disable react/prop-types */
import React from 'react';
import { Icon, Button } from 'antd';
import style from './title.module.scss';
import { withRouter } from 'react-router-dom';

class TitleWithBack extends React.Component {

  static defaultProps = {
    title: "标题"
  }

  constructor(props) {
    super(props)
  }

  backHistory = () => {
    this.props.history.goBack();
  }

  render() {
    const { title } = this.props
    return (
      <div className={style.cont}>
        <Icon className={style.icon} type="appstore" />
        <span className={style.title}>{title}</span>
        <span className={style.back}>
          <Button type="primary" ghost icon="rollback" onClick={this.backHistory}>后退</Button>
        </span>
      </div>
    )
  }
}
export default withRouter(TitleWithBack)